package com.feiyuan.book.app;

import com.feiyuan.book.service.BookUserShelfService;
import com.feiyuan.book.vo.BookShelfVO;
import com.feiyuan.common.annotation.Login;
import com.feiyuan.common.annotation.LoginUser;
import com.feiyuan.common.entity.UserEntity;
import com.feiyuan.common.utils.R;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/app/bqg/shelf")
public class BQGShelfAppController {

    @Autowired
    private BookUserShelfService bookUserShelfService;

    /**
     * 个人书架列表
     * @param user 用户ID
     * @return R
     */
    @GetMapping("/list")
    @Login
    public R list(@LoginUser UserEntity user, @RequestParam Integer pageIndex, @RequestParam Integer pageSize) {
        Map<String, Object> map = bookUserShelfService.bqgList(user.getUserId(), pageIndex, pageSize);
        return R.ok(map);
    }

    /**
     * 删除书架
     * @param bookShelfVO 书架信息
     * @return R
     */
    @PostMapping("/deleteShelf")
    @Login
    public R deleteShelf(@RequestBody BookShelfVO bookShelfVO) {
        Map<String, Object> map = bookUserShelfService.deleteShelf(bookShelfVO);
        return R.ok(map);
    }
}
